Repository navigation
Conversation
Lets a single client route its requests through an HTTP proxy instead of relying on the process-wide http_proxy environment variable. When the option is unset, Net::HTTP keeps reading the proxy from the environment as before. Co-Authored-By: Ajay Kumar <ajay.kumar@workos.com>
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
Original prompt from Ajay
|
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues remain from this review. SummaryAdds an optional per-client HTTP proxy while keeping the existing environment-based behavior when
|
Co-Authored-By: Ajay Kumar <ajay.kumar@workos.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Today the only way to send SDK traffic through a proxy is the
http_proxyenvironment variable, which applies to everyNet::HTTPclient in the process. A customer asked for a way to set it per client so they can roll a proxy out gradually.This adds an optional
proxysetting, available onWorkOS::Client.new(proxy:),WorkOS.configure { |c| c.proxy = ... }andWorkOS::PublicClient.create(proxy:):Behavior:
BaseClient#build_httpstill callsNet::HTTP.new(host, port)with no proxy arguments, sohttp_proxy/no_proxyare read from the environment as before. Passing an explicitnilproxy address would have turned that lookup off, so it is deliberately avoided. The connection cache key is also unchanged for these clients.no_proxydoes not apply to it). Percent-encoded credentials in the URL are decoded before use.http://URLs with a host are accepted (aStringorURI::HTTP); anything else raisesArgumentErrorat construction. The error message never echoes the URL, since it can contain credentials.https://proxy URLs are rejected because the net-http bundled with Ruby 3.3 cannot connect to a proxy over TLS. API traffic is still tunneled with CONNECT and encrypted end to end.connection_keynow appends a SHA-256 of the proxy URL when one is set. Clients with different proxies can't reuse each other's connection, and credentials are not stored in the key.Not included: a per-request
request_options[:proxy]override. Per-client covers the gradual-rollout use case and keeps the change small.Testing:
bundle exec rake testandbundle exec standardrbpass on Ruby 3.3, 3.4 and 4.0.api.workos.comon Ruby 3.3 and 4.0: an explicit proxy is used (with decoded credentials), two clients with different proxies each use their own, a client withoutproxygoes direct, a client withoutproxystill followshttp_proxy, and an explicit proxy wins overhttp_proxy.Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
The README has a new "Proxy" section; no API reference changes.
Link to Devin session: https://workos.devinenterprise.com/sessions/67a6ce68d6d4482eab98a872fb79f92e
Open in Devin Desktop: https://workos.devinenterprise.com/desktop/session/67a6ce68d6d4482eab98a872fb79f92e?variant=devin
Requested by: @ajay-k
🟢 Devin Review found nothing to fix · View findings